{% extends "base.html" %}

{% block content %}
<h1>编辑资产</h1>

<form method="POST">
    <div class="mb-3">
        <label for="name" class="form-label">资产名称 *</label>
        <input type="text" class="form-control" id="name" name="name" value="{{ asset.name }}" required>
    </div>
    
    <div class="mb-3">
        <label for="serial_number" class="form-label">序列号 *</label>
        <input type="text" class="form-control" id="serial_number" name="serial_number" value="{{ asset.serial_number }}" required>
    </div>
    
    <div class="mb-3">
        <label for="asset_type" class="form-label">资产类型 *</label>
        <select class="form-select" id="asset_type" name="asset_type" required>
            <option value="Laptop" {% if asset.asset_type == 'Laptop' %}selected{% endif %}>笔记本电脑</option>
            <option value="Desktop" {% if asset.asset_type == 'Desktop' %}selected{% endif %}>台式机</option>
            <option value="Server" {% if asset.asset_type == 'Server' %}selected{% endif %}>服务器</option>
            <option value="Monitor" {% if asset.asset_type == 'Monitor' %}selected{% endif %}>显示器</option>
            <option value="Printer" {% if asset.asset_type == 'Printer' %}selected{% endif %}>打印机</option>
            <option value="Network Equipment" {% if asset.asset_type == 'Network Equipment' %}selected{% endif %}>网络设备</option>
            <option value="Other" {% if asset.asset_type == 'Other' %}selected{% endif %}>其他</option>
        </select>
    </div>
    
    <div class="mb-3">
        <label for="status" class="form-label">状态</label>
        <select class="form-select" id="status" name="status">
            <option value="Active" {% if asset.status == 'Active' %}selected{% endif %}>在用</option>
            <option value="Inactive" {% if asset.status == 'Inactive' %}selected{% endif %}>闲置</option>
            <option value="In Repair" {% if asset.status == 'In Repair' %}selected{% endif %}>维修中</option>
            <option value="Retired" {% if asset.status == 'Retired' %}selected{% endif %}>已报废</option>
        </select>
    </div>
    
    <div class="mb-3">
        <label for="location" class="form-label">位置</label>
        <input type="text" class="form-control" id="location" name="location" value="{{ asset.location or '' }}">
    </div>
    
    <div class="mb-3">
        <label for="assigned_to_id" class="form-label">负责人</label>
        <select class="form-select" id="assigned_to_id" name="assigned_to_id">
            <option value="">未分配</option>
            {% for user in users %}
            <option value="{{ user.id }}" {% if asset.assigned_to_id == user.id %}selected{% endif %}>
                {{ user.username }}
            </option>
            {% endfor %}
        </select>
    </div>
    
    <div class="mb-3">
        <button type="submit" class="btn btn-primary">更新资产</button>
        <a href="{{ url_for('main.index') }}" class="btn btn-secondary">取消</a>
    </div>
</form>
{% endblock %}